<%@page import="servlet.MyPendingTable"%>
<%@page import="servlet.ApprovalTable1"%>
<%@page import="servlet.AppttypeTable"%>
<%@page import="servlet.PendingApptFilterDropdown"%>
<%@page import="Logic.Authorizer"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
	
<%
	if (session.getAttribute("name") == null) {
		response.sendRedirect("login.jsp");
	} else {
		if (Authorizer.checkRole("1", session.getAttribute("role")
				.toString()) || Authorizer.checkRole("3", session.getAttribute("role").toString())) {

		}
		else
		{
			response.sendRedirect("nopermission.jsp");
						
		}
	}
%>


<!-- Declare the first header -->
<jsp:include page="t_header.jsp" />

<script type="text/javascript">

function getResponsiblity(){
	var value = document.getElementById("getResponsiblity");
	alert(value.value);
}

function setPopup(appointmentID, event){
	
	MyWindow=window.open('appttype_responsibilities.jsp?id='+ appointmentID,'MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=220');
	
	var posy = event.clientY + 5;
	var posx = event.clientX + 20;
	
	MyWindow.moveTo(posx,posy);
}
	

	window.onload = function() {
		<%
		if (request.getParameter("print") != null) {
		if (request.getParameter("print").equals("true")) {
			for (int i = 0; i < Integer.parseInt(request.getAttribute("row").toString());i++){
				String md5 = request.getAttribute("md5" + i).toString();
		%>
		window.open("ApptPrint?md5=<%= md5%>", '_blank');
		<%
			}
			}
			}
		%>
	};

	
	$(document).ready(function(){
		
		var value = document.getElementById("appointmentpendinglist").value;
		
		
		if (value == "all"){
			$(".pendingbody tr").show();
			
		}
		
		else{
		$(".pendingbody tr").show();
		$(".pendingbody tr").not("." +value).hide();
		
		}
		
		$(".appointmentpendinglist").change(function(){
			
			var value = this.value;
			
			if (value == "all"){
				$(".pendingbody tr").show();
				
			}
			
			else{
			$(".pendingbody tr").show();
			$(".pendingbody tr").not("." +value).hide();
			
			}
		});
	});
</script>


<jsp:include page="header.html" />


<!-- Declare sidebar -->
<jsp:include page="t_sidebarappointment.jsp" />

<!-- Main Content -->
<section id="main" class="column">

	<!-- Message -->
	<%
		if (request.getParameter("error") != null) {
			if (request.getParameter("error").equals("1")) {
				out.print("<h4 class='alert_error'>No appointment selected.</h4>");
			} else if (request.getParameter("error").equals("2")) {
				if (request.getParameter("action").equals("approved")) {
					out.print("<h4 class='alert_success'>Appointment approved.</h4>");
				} else if (request.getParameter("action")
						.equals("rejected")) {
					out.print("<h4 class='alert_success'>Appointment rejected.</h4>");
				} else {
					out.print("<h4 class='alert_success'>Appointment delegated.</h4>");
				}

			}

		}
	%>

	<article class="module width_full">
		<header>
		
		<table  style="{border-spacing: 0; }">
		<tr>
		<td  style="width:40%; ">
		
		<h3 id="allormypending" class="tdmar1">Pending Appointments</h3>
	
		</td>
		
		
		
		<td style="width:40%;  "><select id="appointmentpendinglist" class="appointmentpendinglist tdmar3"  style="float: right; margin-bottom: 10px;">
						<%
						
						out.print("<option value=\""+  session.getAttribute("username") + "\">My</option>");
						out.print("<option value=\"all\">All</option>");
						
						%>
		</select></td>
		<td style="width:20%; text-align:left;   "><p class="tdmar2" style="margin-top: 10px;" > Pending Appointments</p></td>
		</tr>
		</table>
			
		</header>

		<form action="StaffAppChangeStatus" method="POST">
			

			<table class="tablesorter" cellspacing="0">
				<thead>
					<tr>
						
						<th>Name</th>
						<th>Appointment</th>
						<th>Description</th>
						<th>Effective Date</th>
						<th>Created By</th>
						<!-- <th>Action</th>  -->
					</tr>
				</thead>
				<tbody class="pendingbody">
					<%
						//if (session.getAttribute("role").equals("3")) {
						//	ApprovalTable1 rt = new ApprovalTable1(out);
						//	rt.doGet(request, response);
						//} else {
						MyPendingTable rt2 = new MyPendingTable(out);
						rt2.doGet(request, response);
						//}
					%>
				</tbody>
			</table>
		</form>


	
	</article>

	<!-- end of content manager article -->
	<div class="spacer"></div>
</section>

<!-- Declare closing tags -->
<jsp:include page="t_footer.jsp" />